package life.exam01;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;

public class LifeBeanImpl implements LifeBean, BeanNameAware, BeanFactoryAware {
	private String beanName;				// 설정파일에서 설정한 bean의 id를 저장할 변수
	private BeanFactory beanFactory;		// The variable to store spring's beanFactory implementer
	
	public void begin() {
		System.out.println("User Initialization Method");
	}
	public void end() {
		System.out.println("User Destroy Method");
	}
	
	public void lifeMethod() {
		System.out.println("Business Logic execution is in progress...");
		System.out.println("beanName: " + beanName);
	}
	
	// This method is used when the bean object should know it's own name.
	// This will be injected the object id value when it is created.
	public void setBeanName(String beanName) {
		this.beanName = beanName;
	}
	
	// The method which spring's BeanFactory will be handed to when the object is created
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.beanFactory = beanFactory;
	}
}
